var _ = require('lodash/core')


class Alphabet {
  constructor(str) {
    this.chars = str.split('')
  }
  function toChar(index) {
  }
  function toIndex(char) {
  }
  function contains(char) {
  }
  function R() {
  }
  function lgR() {
  }
  function toIndices(chars) {
  }
  function toChars(indexs) {
  }
}

function strSort(str='') {
  let strList = str.split('')

  // 统计每一个字符出现次数
  let charCountList = {}
  strList.forEach(function(c) {
    let countItem = charCountList[c]
    if (typeof countItem === 'undefined') {
      charCountList[c] = 1
    } else {
      charCountList[c] += 1
    }
  })
  console.dir(charCountList)

  // 根据 count 生成 index 数组
  // {a: 3, b: 3, c: 4, d: 0}
  // {a: 0, b: 3, c: 6, d: 10} ???
  let countByIndex = {}
  'abcd'.split('').forEach(function(c) {
  })
  console.dir(countByIndex)

  // 回写数组
}

let str = 'abddcdbabcddabcc'
strSort(str)
